<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Category_mgr extends MY_Controller {
	public function page_index($category_id, $page) {
		$category_id = (int) $category_id;
		$page = (int) $page;
		if ($page <= 0) $page = 1;
		$page_size = 10;
		$this->page_data['nav_index'] = 1;
		
		$this->load->model('category_model');
		$category = $this->category_model->get_by_id($category_id);
		$this->page_data['category'] = $category;
		$page_title = htmlspecialchars($category['name']);
		
		$this->load->model('post_model');
		$post_list = $this->post_model->get_simple_list_by_category($category_id, $page, $page_size);
		$total_count = $this->post_model->get_simple_list_by_category_all_count($category_id);
		$this->page_data['post_list'] = $post_list;
		$this->page_data['page'] = $page;
		$this->page_data['page_size'] = $page_size;
		$this->page_data['total_count'] = $total_count;
		$this->page_data['bread_crumb'] = array(
			array('label' => '首页', 'href' => site_url()),
			array('label' => $page_title)
		);
		
		$this->page_data['meta_content'] = $this->load->view('category/meta', $this->page_data, TRUE);
		$this->page_data['main_content'] = $this->load->view('category/main', $this->page_data, TRUE);
		$this->load->view('template/main', $this->page_data);
	}
}